package champPackage;

import java.util.*;

public class TournamentTable {

	/**
	 * constructor is passed a championship 
	 * to create a  championship table
	 * @param ch
	 */
	public TournamentTable(Championship ch){		
		
	}
	
	/**
	 * 
	 * @param id
	 */
	public TournamentTable(int id){
		
	}
	
	/**
	 * computes needed information about the team and adds to table
	 * @param t
	 */
	public void addNewLineToTable(TableLine t){	 		
		set.add(t);
	}
	
	public Iterator<TableLine> getSortedTableLines(){
		return set.iterator();
	}
	
	
	//am setis gamoyenebit gvecodineba romel adgilzea gundi
	private SortedSet<TableLine>set=new TreeSet<TableLine>(new Comparator<TableLine>() {
		@Override
		public int compare(TableLine a, TableLine b) {
			// TODO Auto-generated method stub				
			if(a.getPoint()>b.getPoint())return 1; 
			if(a.getPoint()<b.getPoint())return -1;
			int diff1 = a.getScored()-a.getReceived(), diff2 = b.getScored()-b.getReceived();
			if(diff1>diff2) return 1;
			if(diff1<diff2) return -1;
			return a.getTeamID()-b.getTeamID();
		}
	}); 
	
}
